package com.globallogic.training.javase.easymock;

import com.globallogic.training.javase.university.member.Group;
import com.globallogic.training.javase.university.member.Teacher;

/**
 * This class represents any kind of learning activities
 * within university.
 * @author Ivan Moisiienko
 * @version 0.1 2013/04/12
 */
public abstract class Activity implements Comparable<Activity>{
	
	private Teacher teacher;
	private Group group;
	private int load;
	
	public Activity (int load, Teacher t, Group g) {
		
		if (t == null) {
			throw new IllegalArgumentException("Teacher argument is null");
		}
		
		if (g == null) {
			throw new IllegalArgumentException("Group argument is null");
		}
		
		if (load <= 0 ) {
			throw new IllegalArgumentException("Load should be positive");
		}
		
		this.teacher = t;
		this.group = g;
		this.load = load;
	}
	
	public int getLoad() {
		return load;
	}
	
	public Group getGroup() {
		return group;
	}
	
	public Teacher getTeacher() {
		return teacher;
	}
	
	public String toString() {
		return "[" + teacher.toString() + ", " + group.toString() + "]";
	}
	
	@Override
	public int compareTo(Activity other) {
		if (this.getClass() != other.getClass()) {
			return 1;
		}
		
		String groupId = this.getGroup().getGroupId();
		String otherGroupId = other.getGroup().getGroupId();
		
		return groupId.compareTo(otherGroupId);
	}
	
}
